/**
 * Illustrates loading data from Hive with Spark SQL
 */
package com.hsj;

import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.SQLContext;

/**
 * SparkSql 加载json样例
 */
public class LoadJsonWithSparkSQL {


    public static void main(String[] args) throws Exception {
//        if (args.length != 2) {
//            throw new Exception("Usage LoadJsonWithSparkSQL sparkMaster jsonFile");
//        }
        String master ="local";// args[0];
        String jsonFile ="files/testweet.json";// args[1];

        JavaSparkContext sc = new JavaSparkContext(
                master, "loadJsonwithsparksql");
        SQLContext sqlCtx = new SQLContext(sc);
        Dataset input = sqlCtx.jsonFile(jsonFile);
        input.printSchema();
    }
}
